class PdmsController < ApplicationController

before_filter :login_required, :only => [:new, :edit, :create, :update, :destroy]

  # GET /pdms
  # GET /pdms.xml
  def index
    @pdms = Pdm.all

    respond_to do |format|
      format.html {render :layout => 'layout'} # index.html.erb
      format.xml  { render :xml => @pdms }
    end
  end

  # GET /pdms/1
  # GET /pdms/1.xml
  def show
    @pdm = Pdm.find(params[:id])

    respond_to do |format|
      format.html {render :layout => 'layout'} # show.html.erb
      format.xml  { render :xml => @pdm }
    end
  end

  # GET /pdms/new
  # GET /pdms/new.xml
  def new
    @pdm = Pdm.new

    respond_to do |format|
      format.html {render :layout => 'layout'} # new.html.erb
      format.xml  { render :xml => @pdm }
    end
  end

  # GET /pdms/1/edit
  def edit
    @pdm = Pdm.find(params[:id])
	
	respond_to do |format|
      format.html {render :layout => 'layout'} # edit.html.erb
      format.xml  { render :xml => @pdm }
    end
  end

  # POST /pdms
  # POST /pdms.xml
  def create
    @pdm = Pdm.new(params[:pdm])

    respond_to do |format|
      if @pdm.save
        flash[:notice] = 'Le point de montage a été créé.'
        format.html { redirect_to(@pdm) }
        format.xml  { render :xml => @pdm, :status => :created, :location => @pdm }
      else
        format.html { render :action => "new", :layout => 'layout' }
        format.xml  { render :xml => @pdm.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /pdms/1
  # PUT /pdms/1.xml
  def update
    @pdm = Pdm.find(params[:id])

    respond_to do |format|
      if @pdm.update_attributes(params[:pdm])
        flash[:notice] = 'Le point de montage a été mis à jour.'
        format.html { redirect_to(@pdm) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit", :layout => 'layout' }
        format.xml  { render :xml => @pdm.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /pdms/1
  # DELETE /pdms/1.xml
  def destroy
    @pdm = Pdm.find(params[:id])
    @pdm.destroy

    respond_to do |format|
      format.html { redirect_to(pdms_url) }
      format.xml  { head :ok }
    end
  end
end
